package com.liang.controller;

import com.liang.service.GoodsStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * Created with Intellij IDEA
 *
 * @Auther: liangjy
 * @Date: 2022/01/07/14:42
 * @Description:
 */
@Controller
@RequestMapping("/")
public class GoosController {
    @Autowired
    private GoodsStoreService goodsStoreService;

    /**
     * 进入测试页面
     *
     * @param model
     * @return
     */
    @GetMapping("")
    public String Index(Model model) {
        return "index";
    }

    /**
     * 秒杀提交
     *
     * @param code
     * @param num
     * @return
     */
    @PostMapping("secKill")
    @ResponseBody
    public String secKill(@RequestParam(value = "code", required = true) String code, @RequestParam(value = "num", required = true) Integer num) {
        String reString = goodsStoreService.updateGoodsStore(code, num);
        return reString;
    }
}
